<template>
  <el-dialog
    :title="$t('shop.cate.name')"
    v-model="dd.show"
    :width="store.dialogWidth"
    :close-on-click-modal="false"
    @close="dd.show = false"
  >
    <slot></slot>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dd.show = false">{{ $t('common.cancel') }}</el-button>
        <el-button :loading="dd.loading" type="primary" @click="saveRecord">{{ $t('common.sure') }}</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
// do not use
const store = useAppStore()

// detailDialog
const dd = reactive({
  show: false,
  loading: false,
  action: 0 as ListAction,
  item: {} as ApiCategory
})

const ddDisable = computed(() => dd.action == 1)

const detail = (row: ApiCategory, action: ListAction) => {
  dd.show = true
  dd.action = action
  if (action == 0) {
    dd.item = {}
  }
}

const saveRecord = () => {
  dd.show = true
  dd.item = {}
}

const del = (row: ApiCategory) => {
  apis.api.shopDelCategory({ id: row.id! }).then(() => getList())
}
</script>
